module two {
	export class JewelryInfoItem extends eui.ItemRenderer implements eui.UIComponent {
		public constructor() {
			super();
		}
		protected childrenCreated(): void {
			super.childrenCreated();

			this.icon.visible = false;
			this.width = GameUtils.getSceneWidth();
		}

		private jewMC: one.DynamicFrames;

		public icon:eui.Image;
		public gp_bar:eui.Group;
		public bar_thumb:eui.Image;
		public bar_star:eui.Image;

		data: IJewelryConfig;

		private cnt:number = 0;
		protected dataChanged(): void {
			super.dataChanged();
			this.width = GameUtils.getSceneWidth();

			if (!this.data.id) {
				return;
			}

			this.cnt++;

			let cfg = this.data;

			if (this.jewMC && this.jewMC.parent) {
				this.jewMC.parent.removeChild(this.jewMC);
			}
			this.icon.visible = false;
			this.gp_bar.visible = false;
			// if (User_getMyJewelryProxy.getInstance().getJewerlyCodeByJewId(this.data.id)) {
				var frames = {
					run: [],
					stand: [1],
				};

				let keys: string[] = [];
				for (let i = 1; i <= cfg.count[1]; i++) {
					frames.run.push("" + i);

					keys.push(cfg.star + "_" + cfg.icon + "_" + i + "_jpg");
				}
				RES.createGroup("jewlry_" + cfg.star + "_" + cfg.icon, keys, true);
				let loads = ["jewlry_" + cfg.star + "_" + cfg.icon];

				this.bar_thumb.width = 0;
				this.bar_star.x = 0;

				let tempCnt = this.cnt;
				one.loaderManager.loadGroups(loads, 100, (current: number, total: number) => {
					if (tempCnt != this.cnt) {
						return;
					}
					this.gp_bar.visible = true;
					this.bar_thumb.width = this.bar_star.x = Math.floor(current / total * this.gp_bar.width);
					if (current == total) {
						this.gp_bar.visible = false;

						let mc = this.jewMC = new one.DynamicFrames(frames, cfg.star + "_" + cfg.icon, "jpg");
						mc.width = 440;
						mc.height = 440;
						mc.play('run');
						this.addChild(mc);
						mc.x = this.width / 2 - 440 / 2;
						mc.y = 440 / 2 - 440 / 2;
					}
				})
			// }
			// else {
			// 	this.icon.visible = true;
			// 	this.icon.source = "";
			// 	this.icon.source = cfg.star + "_" + cfg.icon + "_" + 1 + "_jpg";
			// }

		}
	}
}